package com.book.service.impl;

import com.book.bean.Category;
import com.book.dao.CategoryDao;
import com.book.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CategoryServiceImpl implements CategoryService {
    //spring的注入标签，该标签的作用实例化CategoryDao对象

    @Autowired
    private CategoryDao categoryDao;

    public List<Category> listPager(int page , int size,String catename) {
        return categoryDao.listPager((page-1)*size,size,catename);
    }

    public int count(){
        return categoryDao.count();
    }

    public boolean saveCategory(Category category) {
        return categoryDao.insert(category) > 0;
    }

    public boolean updateCategory(Category category) {

        return categoryDao.update(category) > 0;
    }

    public boolean removeCategory(int cateid) {

        return categoryDao.delete(cateid) > 0;
    }
}
